#ifndef _TEXTURE_
#define _TEXTURE_

#include "../core/unicode.h"
#include "../core/hashmap.h"


#define PVRMIPMAP_MAX	16

struct PVRMipmap {
	unsigned char *address;
	unsigned int len;
};


class CTexture
{
public :
	CTexture();

	static	bool	Open(const wchar *filename);
	static	bool	Create();
	void	Release();

private :
	bool	unpackPVRData(unsigned char* data, unsigned int len);

	GLuint		texture;

	struct PVRMipmap m_asMipmaps[PVRMIPMAP_MAX];   // pointer to mipmap images    
	bool m_bHasAlpha;
	unsigned int m_uWidth, m_uHeight;
	unsigned int m_uNumberOfMipmaps;                    // number of mipmap used
	unsigned int m_uTableFormatIndex;
};


//////////////////////////////////////////////////////////////////////////

class CTextureMan
{
public :
	CTextureMan();
	~CTextureMan();


	CTexture*	Open(const wchar *filename);
	bool		Release(CTexture* texture);



private :
	core::hashmap<unicode::string, CTexture>	m_cachetextures;

};


#endif